import React from 'react'
import { Switch, Route, Redirect } from 'react-router-dom'
export default function RouterView(props) {
    const comList = props.routes.filter(item => item.component)
    const redList = props.routes.filter(item => item.from)
    return (
        <Switch>
            {comList.map(item => {
                return <Route path={item.path} key={item.path} render={(history) => {
                    return <item.component {...history} routes={item.children || []}></item.component>
                }}></Route>
            })}
            {redList.map(item => {
                return <Redirect {...item} key={item.from}></Redirect>
            })}
        </Switch>
    )
}
